package com.example.sharingjdbc4digiwin.controller;

import com.example.sharingjdbc4digiwin.mapper.DataDayMapper;
import com.example.sharingjdbc4digiwin.entity.DataDay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author： ygl
 * @date： 2019/06/22
 * @Description：
 */
@RestController
@RequestMapping("/data/day")
public class DataDayController {

    @Autowired
    private DataDayMapper dataDayMapper;

    @PostMapping
    public int insert(@RequestBody DataDay model){
       return dataDayMapper.insert(model);
    }

    @GetMapping("/{page}")
    public List<DataDay> list(@PathVariable int page,@RequestParam String serverName){
        String start = "2019-06-01 00:54:38";
        String end = "2019-07-30 23:54:38";
        List<DataDay> list = dataDayMapper.list(start, end, page,serverName);
        return list;
    }

    @GetMapping("/find/{time}")
    public List<DataDay> find(@PathVariable String time){
        List<DataDay> dataDays = dataDayMapper.find(time);
        return dataDays;
    }
}
